package de.karlNet.sambamanager.ldapController.commands;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Controller;

import de.karlNet.sambamanager.ldapController.commands.attributeBuilder.CNameRecordBuilder;
import de.karlNet.sambamanager.ldapModel.dns.LdapDNSCName;

@Controller
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class CreateCName extends BaseCommand {
	@Autowired
	private CNameRecordBuilder cNameRecordBuilder;

	public void createCName(LdapDNSCName ldapDNSCName) throws UnsupportedEncodingException {
		this.ldapTemplate.bind(ldapDNSCName.getDn(), null,
				this.cNameRecordBuilder
						.buildARecordAttributesWithDC(ldapDNSCName));
	}
}
